

TOOL.Category		= "Render"
TOOL.Name			= "#Material"
TOOL.Command		= nil
TOOL.ConfigName		= ""


TOOL.ClientConVar[ "override" ] = "debug/env_cubemap_model"

local function SetMaterial( Player, Entity, Data )
	if SERVER then
		Entity:SetMaterial( Data.MaterialOverride )
	end
	if ( SERVER ) then
		duplicator.StoreEntityModifier( Entity, "material", Data )
	end

	return true

end
duplicator.RegisterEntityModifier( "material", SetMaterial )

function TOOL:LeftClick( trace )

	if !( trace.Entity &&			// Hit an entity
	      trace.Entity:IsValid() && 	// And the entity is valid
	      trace.Entity:EntIndex() != 0	// And isn't worldspawn
	    ) then return end
		
	local mat = self:GetClientInfo( "override" )
	SetMaterial( self:GetOwner(), trace.Entity, { MaterialOverride = mat } )
	return true


end



function TOOL:RightClick( trace )

	if !( trace.Entity &&			// Hit an entity
	      trace.Entity:IsValid() && 	// And the entity is valid
	      trace.Entity:EntIndex() != 0	// And isn't worldspawn
	    ) then return end
	SetMaterial( self:GetOwner(), trace.Entity, { MaterialOverride = "" } )
	return true

end

list.Add( "OverrideMaterials", "debug/env_cubemap_model" )
list.Add( "OverrideMaterials", "models/shadertest/shader3" )
list.Add( "OverrideMaterials", "models/shadertest/shader4" )
list.Add( "OverrideMaterials", "models/shadertest/shader5" )
list.Add( "OverrideMaterials", "models/shiny" )
list.Add( "OverrideMaterials", "models/debug/debugwhite" )
list.Add( "OverrideMaterials", "Models/effects/comball_sphere" )
list.Add( "OverrideMaterials", "Models/effects/comball_tape" )
list.Add( "OverrideMaterials", "Models/effects/splodearc_sheet" )
list.Add( "OverrideMaterials", "Models/effects/vol_light001" )
list.Add( "OverrideMaterials", "models/props_combine/stasisshield_sheet" )
list.Add( "OverrideMaterials", "models/props_combine/portalball001_sheet" )
list.Add( "OverrideMaterials", "models/props_combine/com_shield001a" )
list.Add( "OverrideMaterials", "models/props_c17/frostedglass_01a" )
list.Add( "OverrideMaterials", "models/props_lab/Tank_Glass001" )
list.Add( "OverrideMaterials", "models/props_combine/tprings_globe" )
list.Add( "OverrideMaterials", "models/rendertarget" )
list.Add( "OverrideMaterials", "models/screenspace" )
list.Add( "OverrideMaterials", "brick/brick_model" )
list.Add( "OverrideMaterials", "models/props_pipes/GutterMetal01a" )
list.Add( "OverrideMaterials", "models/props_pipes/Pipesystem01a_skin3" )
list.Add( "OverrideMaterials", "models/props_wasteland/wood_fence01a" )
list.Add( "OverrideMaterials", "models/props_foliage/tree_deciduous_01a_trunk" )
list.Add( "OverrideMaterials", "models/props_c17/FurnitureFabric003a" )
list.Add( "OverrideMaterials", "models/props_c17/FurnitureMetal001a" )
list.Add( "OverrideMaterials", "models/props_c17/paper01" )
list.Add( "OverrideMaterials", "models/flesh" )
list.Add( "OverrideMaterials", "models/airboat/airboat_blur02" )
list.Add( "OverrideMaterials", "models/alyx/emptool_glow" )
list.Add( "OverrideMaterials", "models/antlion/antlion_innards" )	
list.Add( "OverrideMaterials", "models/barnacle/roots" )
list.Add( "OverrideMaterials", "models/combine_advisor/body9" )
list.Add( "OverrideMaterials", "models/combine_advisor/mask" )
list.Add( "OverrideMaterials", "models/combine_scanner/scanner_eye" )
list.Add( "OverrideMaterials", "models/debug/debugwhite" )
list.Add( "OverrideMaterials", "models/dog/eyeglass" )
list.Add( "OverrideMaterials", "models/effects/comball_glow1" )
list.Add( "OverrideMaterials", "models/effects/comball_glow2" )
list.Add( "OverrideMaterials", "models/effects/portalrift_sheet" )
list.Add( "OverrideMaterials", "models/effects/slimebubble_sheet" )
list.Add( "OverrideMaterials", "models/effects/splode1_sheet" )
list.Add( "OverrideMaterials", "models/effects/splodearc_sheet" )
list.Add( "OverrideMaterials", "models/effects/splode_sheet" )
list.Add( "OverrideMaterials", "models/effects/vol_light001" )
list.Add( "OverrideMaterials", "models/gibs/woodgibs/woodgibs01" )
list.Add( "OverrideMaterials", "models/gibs/woodgibs/woodgibs02" )
list.Add( "OverrideMaterials", "models/gibs/woodgibs/woodgibs03" )
list.Add( "OverrideMaterials", "models/gibs/metalgibs/metal_gibs" )
list.Add( "OverrideMaterials", "models/items/boxsniperrounds" )
list.Add( "OverrideMaterials", "models/player/player_chrome1" )
list.Add( "OverrideMaterials", "models/props_animated_breakable/smokestack/brickwall002a" )
list.Add( "OverrideMaterials", "models/props_building_details/courtyard_template001c_bars" )
list.Add( "OverrideMaterials", "models/props_building_details/courtyard_template001c_bars" )
list.Add( "OverrideMaterials", "models/props_buildings/destroyedbuilldingwall01a" )
list.Add( "OverrideMaterials", "models/props_buildings/plasterwall021a" )
list.Add( "OverrideMaterials", "models/props_c17/frostedglass_01a" )
list.Add( "OverrideMaterials", "models/props_c17/furniturefabric001a" )
list.Add( "OverrideMaterials", "models/props_c17/furniturefabric002a" )
list.Add( "OverrideMaterials", "models/props_c17/furnituremetal001a" )
list.Add( "OverrideMaterials", "models/props_c17/gate_door02a" )
list.Add( "OverrideMaterials", "models/props_c17/metalladder001" )
list.Add( "OverrideMaterials", "models/props_c17/metalladder002" )
list.Add( "OverrideMaterials", "models/props_c17/metalladder003" )
list.Add( "OverrideMaterials", "models/props_canal/canalmap_sheet" )
list.Add( "OverrideMaterials", "models/props_canal/canal_bridge_railing_01a" )
list.Add( "OverrideMaterials", "models/props_canal/canal_bridge_railing_01b" )
list.Add( "OverrideMaterials", "models/props_canal/canal_bridge_railing_01c" )
list.Add( "OverrideMaterials", "models/props_canal/coastmap_sheet" )
list.Add( "OverrideMaterials", "models/props_canal/metalcrate001d" )
list.Add( "OverrideMaterials", "models/props_canal/metalwall005b" )
list.Add( "OverrideMaterials", "models/props_canal/rock_riverbed01a" )
list.Add( "OverrideMaterials", "models/props_combine/citadel_cable" )
list.Add( "OverrideMaterials", "models/props_combine/citadel_cable_b" )
list.Add( "OverrideMaterials", "models/props_combine/combine_interface_disp" )
list.Add( "OverrideMaterials", "models/props_combine/combine_monitorbay_disp" )
list.Add( "OverrideMaterials", "models/props_combine/com_shield001a" )
list.Add( "OverrideMaterials", "models/props_combine/health_charger_glass" )
list.Add( "OverrideMaterials", "models/props_combine/metal_combinebridge001" )
list.Add( "OverrideMaterials", "models/props_combine/pipes01" )
list.Add( "OverrideMaterials", "models/props_combine/pipes03" )
list.Add( "OverrideMaterials", "models/props_combine/prtl_sky_sheet" )
list.Add( "OverrideMaterials", "models/props_combine/stasisfield_beam" )
list.Add( "OverrideMaterials", "models/props_debris/building_template010a" )
list.Add( "OverrideMaterials", "models/props_debris/building_template022j" )
list.Add( "OverrideMaterials", "models/props_debris/composite_debris" )
list.Add( "OverrideMaterials", "models/props_debris/concretefloor013a" )
list.Add( "OverrideMaterials", "models/props_debris/concretefloor020a" )
list.Add( "OverrideMaterials", "models/props_debris/concretewall019a" )
list.Add( "OverrideMaterials", "models/props_debris/metalwall001a" )
list.Add( "OverrideMaterials", "models/props_debris/plasterceiling008a" )
list.Add( "OverrideMaterials", "models/props_debris/plasterwall009d" )
list.Add( "OverrideMaterials", "models/props_debris/plasterwall021a" )
list.Add( "OverrideMaterials", "models/props_debris/plasterwall034a" )
list.Add( "OverrideMaterials", "models/props_debris/plasterwall034d" )
list.Add( "OverrideMaterials", "models/props_debris/plasterwall039c" )
list.Add( "OverrideMaterials", "models/props_debris/plasterwall040c" )
list.Add( "OverrideMaterials", "models/props_debris/tilefloor001c" )
list.Add( "OverrideMaterials", "models/props_foliage/driftwood_01a" )
list.Add( "OverrideMaterials", "models/props_foliage/oak_tree01" )
list.Add( "OverrideMaterials", "models/props_foliage/tree_deciduous_01a_trunk" )
list.Add( "OverrideMaterials", "models/props_interiors/metalfence007a" )
list.Add( "OverrideMaterials", "models/props_junk/plasticcrate01a" )
list.Add( "OverrideMaterials", "models/props_junk/plasticcrate01b" )
list.Add( "OverrideMaterials", "models/props_junk/plasticcrate01c" )
list.Add( "OverrideMaterials", "models/props_junk/plasticcrate01d" )
list.Add( "OverrideMaterials", "models/props_junk/plasticcrate01e" )
list.Add( "OverrideMaterials", "models/props_lab/cornerunit_cloud" )
list.Add( "OverrideMaterials", "models/props_lab/door_klab01" )
list.Add( "OverrideMaterials", "models/props_lab/security_screens" )
list.Add( "OverrideMaterials", "models/props_lab/security_screens2" )
list.Add( "OverrideMaterials", "models/props_lab/Tank_Glass001" )
list.Add( "OverrideMaterials", "models/props_lab/warp_sheet" )
list.Add( "OverrideMaterials", "models/props_lab/xencrystal_sheet" )
list.Add( "OverrideMaterials", "models/props_pipes/destroyedpipes01a" )
list.Add( "OverrideMaterials", "models/props_pipes/GutterMetal01a")
list.Add( "OverrideMaterials", "models/props_pipes/pipemetal001a" )
list.Add( "OverrideMaterials", "models/props_pipes/pipeset_metal02" )
list.Add( "OverrideMaterials", "models/props_pipes/pipesystem01a_skin1" )
list.Add( "OverrideMaterials", "models/props_pipes/pipesystem01a_skin2" )
list.Add( "OverrideMaterials", "models/props_vents/borealis_vent001" )
list.Add( "OverrideMaterials", "models/props_vents/borealis_vent001b" )
list.Add( "OverrideMaterials", "models/props_vents/borealis_vent001c" )
list.Add( "OverrideMaterials", "models/props_wasteland/concretefloor010a" )
list.Add( "OverrideMaterials", "models/props_wasteland/concretewall064b" )
list.Add( "OverrideMaterials", "models/props_wasteland/concretewall066a" )
list.Add( "OverrideMaterials", "models/props_wasteland/dirtwall001a" )
list.Add( "OverrideMaterials", "models/props_wasteland/metal_tram001a" )
list.Add( "OverrideMaterials", "models/props_wasteland/quarryobjects01" )
list.Add( "OverrideMaterials", "models/props_wasteland/rockcliff02a" )
list.Add( "OverrideMaterials", "models/props_wasteland/rockcliff02b" )
list.Add( "OverrideMaterials", "models/props_wasteland/rockcliff02c" )
list.Add( "OverrideMaterials", "models/props_wasteland/rockcliff04a" )
list.Add( "OverrideMaterials", "models/props_wasteland/rockgranite02a" )
list.Add( "OverrideMaterials", "models/props_wasteland/tugboat01" )
list.Add( "OverrideMaterials", "models/props_wasteland/tugboat02" )
list.Add( "OverrideMaterials", "models/props_wasteland/wood_fence01a" )
list.Add( "OverrideMaterials", "models/props_wasteland/wood_fence01a_skin2" )
list.Add( "OverrideMaterials", "models/roller/rollermine_glow" )
list.Add( "OverrideMaterials", "models/weapons/v_crossbow/rebar_glow" )
list.Add( "OverrideMaterials", "models/weapons/v_crowbar/crowbar_cyl" )
list.Add( "OverrideMaterials", "models/weapons/v_grenade/grenade body" )
list.Add( "OverrideMaterials", "models/weapons/v_smg1/texture5" )
list.Add( "OverrideMaterials", "models/weapons/w_smg1/smg_crosshair" )
list.Add( "OverrideMaterials", "models/weapons/v_slam/new light2" )
list.Add( "OverrideMaterials", "models/weapons/v_slam/new light1" )
list.Add( "OverrideMaterials", "models/props/cs_assault/dollar" )
list.Add( "OverrideMaterials", "models/props/cs_assault/fireescapefloor" )
list.Add( "OverrideMaterials", "models/props/cs_assault/metal_stairs1" )
list.Add( "OverrideMaterials", "models/props/cs_assault/moneywrap" )
list.Add( "OverrideMaterials", "models/props/cs_assault/moneywrap02" )
list.Add( "OverrideMaterials", "models/props/cs_assault/moneytop" )
list.Add( "OverrideMaterials", "models/props/cs_assault/pylon" )
list.Add( "OverrideMaterials", "models/props/CS_militia/boulder01" )
list.Add( "OverrideMaterials", "models/props/CS_militia/milceil001" )
list.Add( "OverrideMaterials", "models/props/CS_militia/militiarock" )
list.Add( "OverrideMaterials", "models/props/CS_militia/militiarockb" )
list.Add( "OverrideMaterials", "models/props/CS_militia/milwall006" )
list.Add( "OverrideMaterials", "models/props/CS_militia/rocks01" )
list.Add( "OverrideMaterials", "models/props/CS_militia/roofbeams01" )
list.Add( "OverrideMaterials", "models/props/CS_militia/roofbeams02" )
list.Add( "OverrideMaterials", "models/props/CS_militia/roofbeams03" )
list.Add( "OverrideMaterials", "models/props/CS_militia/RoofEdges" )
list.Add( "OverrideMaterials", "models/props/cs_office/clouds" )
list.Add( "OverrideMaterials", "models/props/cs_office/file_cabinet2" )
list.Add( "OverrideMaterials", "models/props/cs_office/file_cabinet3" )
list.Add( "OverrideMaterials", "models/props/cs_office/screen" )
list.Add( "OverrideMaterials", "models/props/cs_office/snowmana" )
list.Add( "OverrideMaterials", "models/props/de_inferno/de_inferno_boulder_03" )
list.Add( "OverrideMaterials", "models/props/de_inferno/infflra" )
list.Add( "OverrideMaterials", "models/props/de_inferno/infflrd" )
list.Add( "OverrideMaterials", "models/props/de_inferno/inftowertop" )
list.Add( "OverrideMaterials", "models/props/de_inferno/offwndwb_break" )
list.Add( "OverrideMaterials", "models/props/de_inferno/roofbits" )
list.Add( "OverrideMaterials", "models/props/de_inferno/tileroof01" )
list.Add( "OverrideMaterials", "models/props/de_inferno/woodfloor008a" )
list.Add( "OverrideMaterials", "models/props/de_nuke/nukconcretewalla" )
list.Add( "OverrideMaterials", "models/props/de_nuke/nukecardboard" )
list.Add( "OverrideMaterials", "models/props/de_nuke/pipeset_metal" )
list.Add( "OverrideMaterials", "models/shadertest/predator" )



function TOOL.BuildCPanel( CPanel )

	// HEADER
	CPanel:SetTooltip( "#Tool_material_desc" )
	
	CPanel:MatSelect( "material_override", list.Get( "OverrideMaterials" ), true, 0.33, 0.33 )
									
end


